<?php

include(dirname(__FILE__) . '/../../bootstrap/functional.php');

$browser = new TrueTraderTestFunctional(new sfBrowser());
$browser->loadData()->restart();

$browser->
  info('1 - User authentification')->
  info('  1.1 - Submit a user with only empty field')->
  get('/login')->
  with('request')->begin()->
    isParameter('module', 'sfGuardAuth')->
    isParameter('action', 'signin')->
  end()->
  click('Connexion', array('signin' => array(
    'username' => '',
    'password' => '',
    )), array('position' => 2))->
  with('form')->begin()->
    hasErrors(3)->
      isError('username', 'required')->
      isError('password', 'required')->
      hasGlobalError('invalid')->
  end()->

  info('  1.2 - Submit a user with wrong username and password')->
  with('request')->begin()->
    isParameter('module', 'sfGuardAuth')->
    isParameter('action', 'signin')->
  end()->
  click('Connexion', array('signin' => array(
    'username' => 'test',
    'password' => 'test',
    )), array('position' => 2))->
  with('form')->begin()->
    hasGlobalError('invalid')->
  end()
;
